#include "GridRenderPass.h"
#include <SERender/Renderer/Renderer.h>
#include <SERender/Renderer/RenderFeature/RenderFeature.h>
#include <SEEdit/Render/RenderFeature/DebugRenderFeature.h>
#include <SEEdit/Descriptors/RenderSettingDescriptor.h>
#include <SECore/CoreApplication.h>

namespace SEngine
{    
    void GridRenderPass::DrawFrame()
    {
        auto & renderSettingDes = CoreApplication::App().GetDescriptor<RenderSettingDescriptor>()->get();
        auto & debugFeature = m_renderer.Descriptor<RenderFeature>::GetDescriptor<DebugRenderFeature>()->get();
        const float length = 10000.0f;
        if (renderSettingDes.isShowGrid) {
            debugFeature.DrawGrid(10000.0f, 10.0f, glm::vec4{glm::vec3(0.5f), renderSettingDes.grid}, 1.0f, glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3{1.0f, 0.0f, 0.0f}));
            debugFeature.DrawLine(glm::vec3{-length * 0.5f, 0.0f, 0.0f}, glm::vec3{length * 0.5f, 0.0f, 0.0f}, glm::vec4{1.0f, 0.0f, 0.0f, 1.0f}, 3.0f);   // x
            debugFeature.DrawLine(glm::vec3{0.0f, -length * 0.5f, 0.0f}, glm::vec3{0.0f, length * 0.5f, 0.0f}, glm::vec4{0.0f, 1.0f, 0.0f, 1.0f}, 3.0f);   // y
            debugFeature.DrawLine(glm::vec3{0.0f, 0.0f, -length * 0.5f}, glm::vec3{0.0f, 0.0f, length * 0.5f}, glm::vec4{0.0f, 0.0f, 1.0f, 1.0f}, 3.0f);   // z
        }
    }
} // namespace SEngine

